package org.forever.view
{
	import flash.events.MouseEvent;
	
	import mx.collections.ArrayList;
	import mx.core.IUIComponent;
	
	import spark.components.SkinnableContainer;
	
	/**容器类*/ 
	public class ResizeContainer
	{ 
		/**显示所有可变组件的容器*/
		private var _app_container:SkinnableContainer;
		/**当前指向的可变组件*/
		private var _current_resizeUI:ResizeUI;
		/**注册可变组件的容器*/
		private var _resizeUIList:ArrayList; 
		/**移动时候的回调函数*/
		private var _mouseMoveCallFun:Function;
 
		/**初始化方法*/
		public function ResizeContainer(app_container:SkinnableContainer){
			_app_container = app_container;
			initContainer();
			_resizeUIList = new ArrayList();
		}
		
		/**注册可变组件*/
		public function register(uicomp:IUIComponent):void{	
			var _resizeUI:ResizeUI = new ResizeUI(uicomp,_app_container);
			_resizeUI.resizeContainer = this;
			_resizeUIList.addItem(_resizeUI);
		} 
		
		/**初始化容器事件*/ 
		public function initContainer():void{
			_app_container.addEventListener(MouseEvent.MOUSE_DOWN,appContainerMouseDownHandler);
			_app_container.addEventListener(MouseEvent.MOUSE_MOVE,appContainerMouseMoveHandler);
			_app_container.addEventListener(MouseEvent.MOUSE_UP,appContainerMouseUpHandler);
		}
		
		public function appContainerMouseDownHandler(event:MouseEvent):void{
			event.stopImmediatePropagation();
			if(null!=_current_resizeUI){
				_current_resizeUI.hideResizeUI();	
			}
		}
		
		public function appContainerMouseMoveHandler(event:MouseEvent):void{
			if(null != _mouseMoveCallFun){
				_mouseMoveCallFun(event);
			}
		}
		
		public function appContainerMouseUpHandler(event:MouseEvent):void{
			if(null != _mouseMoveCallFun){
				_mouseMoveCallFun = null;
				if(null!=_current_resizeUI)_current_resizeUI.updateUIComp();
			}
		}
		
		/******************get and set************************/
		public function get mouseMoveCallFun():Function
		{
			return _mouseMoveCallFun;
		}

		public function set mouseMoveCallFun(value:Function):void
		{
			_mouseMoveCallFun = value;
		}
		
		public function get current_resizeUI():ResizeUI
		{
			return _current_resizeUI; 
		}

		public function set current_resizeUI(value:ResizeUI):void
		{ 
			if(null!=_current_resizeUI){
				_current_resizeUI.hideResizeUI();	
			}
			_current_resizeUI = value;
			
		}
		
	}
}